#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll p = 998244353;
ll n, q;
ll a[200010];
ll gcdd(ll x, ll y)
{
    if(x > y)
    {
        ll tmp = x;
        x = y;
        y = tmp;
    }
    while(y % x)
    {
        ll tmp = y % x;
        y = x;
        x = tmp;
    }
    return x;
}
int main()
{
    // 请在此输入您的代码
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> q;
    for(ll i = 1; i <= n; i++)
        cin >> a[i];
    while(q--)
    {
        ll op, l, r, v;
        cin >> op;
        if(op == 1)
        {
            cin >> l >> r;
            ll res = 0;
            for(ll i = l; i <= r; i++)
                res = (res + a[i]) % p;
            cout << res << "\n";
        }
        if(op == 2)
        {
            cin >> l >> r >> v;
            for(ll i = l; i <= r; i++)
                a[i] = (a[i] / gcdd(a[i], v)) % p;
        }
        if(op == 3)
        {
            cin >> l >> v;
            a[l] = a[l] * gcdd(a[l], v) % p;
        }
    }
    return 0;
}